/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: twp
 * Date: 2024-05-01
 * Time: 22:17
 */

import java.util.Random;
import java.util.Scanner;
public class Test {
    public static boolean is_leap_year(int year){//判断是否为闰年
        if(year%400==0||((year%400!=0)&&(year%4==0))){
            return true;
        }else{
            return false;
        }
    }
    public static int ADD(int a,int b){//SB加法
        return a+b;
    }
     public static void print(int n){//正向输出
         if (n < 10) {
             System.out.println(n);
             return;
         }else{
           print(n/10);
             System.out.println(n%10);
         }
     }
    public static int sum(int n){//高斯的题
        if(n==0){
            return 0;
        }else{
            return n + sum(n - 1);
        }
    }
    public static int SUM(int n){//一个数每一位的和
        if(n<10){
            return n;
        }else{
            return n%10+SUM(n/10);
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n= scanner.nextInt();
        System.out.println(SUM(n));
    }
    public static void main7(String[] args) {
        System.out.println(sum(10));
    }
    public static void main6(String[] args) {
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       print(n);
    }
    public static void main5(String[] args) {
    Scanner x = new Scanner(System.in);
    int a = x.nextInt();
    int b = x.nextInt();
    int n = ADD(a,b);
        System.out.println(n);
    }
    public static void main4(String[] args) {
       Scanner ai = new Scanner(System.in);
       int year = ai.nextInt();
       if(is_leap_year(year)){
           System.out.println("是闰年");
       }else{
           System.out.println("不是闰年");
       }
    }
    public static void main3(String[] args) {
        Random random = new Random();
        int randnum = random.nextInt(100);//生成[0-100]的随机数
        System.out.println(randnum);
        while (true){
            System.out.println("请输入你要猜的数字");
            Scanner a = new Scanner(System.in);
            int n= a.nextInt();
            if(n>randnum){
                System.out.println("猜大了");
            }else if(n<randnum){
                System.out.println("猜小了");
            }else if(n==randnum){
                System.out.println("猜对了");
                break;
            }
        }
    }
    public static void main2(String[] args) {
   /* while(i<=100){
     if(i%15!=0){
         i++;
         continue;
     }
        System.out.println(i);
        i++;
    }*/
     /*   for (int i=1; i < 100; i++) {
            if(i%15!=0){
                i++;
                continue;
            }
            System.out.println(i);
        }*/
        /*Scanner scanner = new Scanner(System.in);//输入，求图形
        while (scanner.hasNextInt()){
            int n= scanner.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if(i==j||i+j==(n-1)) {
                        System.out.print("*");
                    }else {
                        System.out.print(" ");
                    }
                }
                System.out.println("\n");
            }
        }*/

       /* for (int i = 1; i <9999 ; i++) {//求水仙花数
            int count = 0;
            int tmp = i;
            while(tmp!=0){
                count++;
                tmp /= 10;
            }
            int t=0;
            tmp = i;
            while(tmp!=0){
                t += Math.pow(tmp % 10,count);
                tmp /= 10;
            }
            if(t==i){
                System.out.println(i);
            }
        }*/
        /*double sum=0;
        double flg=1.0;
        for (int i = 1; i <= 100; i++) {
         //flg=Math.pow(flg,i+1);
            sum+=(1.0/i)*flg;
            flg=-flg;
        }
        System.out.println(sum);*/
       /* int a = 24;
        int b = 18;
        int c = a%b;
        while(c!=0){
            a=b;
            b=c;
            c=a%b;
        }
        System.out.println(b);*/
        /*int n = 7;
        int count = 0;
        while(n!=0){
            n = n&(n-1);
            count++;
        }
        System.out.println(count);*/
    }
}